/**
 * 
 */
package edu.umd.clip.lm.storage.remote;

import java.nio.ByteBuffer;

/**
 * @author Denis Filimonov <den@cs.umd.edu>
 *
 */
public class SingleTreeRequestMessage extends Message {
	private int clusterid;
	private long factorBits;
	public static final int SIZE = 4 + 8;

	public SingleTreeRequestMessage(int modelId, int clusterid, long factorBits) {
		super(MessageHeader.SINGLE_TREE_REQUEST, modelId, SIZE);
		this.clusterid = clusterid;
		this.factorBits = factorBits;
	}

	public SingleTreeRequestMessage(MessageHeader header, ByteBuffer buffer) {
		super(header);
		readBody(buffer);
	}
	
	protected void readBody(ByteBuffer buffer) {
		clusterid = buffer.getInt();
		factorBits = buffer.getLong();
	}
	
	protected ByteBuffer writeBody() {
		ByteBuffer buffer = ByteBuffer.allocate(SIZE);
		buffer.putInt(clusterid);
		buffer.putLong(factorBits);
		return buffer;
	}
	
	public int getClusterid() {
		return clusterid;
	}

	public long getFactorBits() {
		return factorBits;
	}
	
}
